<?php


namespace App\Http\Controllers\Api;


use App\Exceptions\BusinessException;
use App\Helpers\Libraries\UploadLibrary;
use App\Http\Controllers\BaseController;

class UploadController extends BaseController
{

    /**
     * 上传图片
     * @return array
     * @throws BusinessException
     */
    public function image(): array
    {
        $rule = ['jpg', 'png', 'gif'];
        return UploadLibrary::uploadFile('images', $rule, 5);
    }

    /**
     * 上传视频
     * @return array
     * @throws BusinessException
     */
    public function video(): array
    {
        $rule = ['mp4'];
        return UploadLibrary::uploadFile('videos', $rule, 20);
    }

    /**
     * 上传音频
     * @return array
     * @throws BusinessException
     */
    public function audio(): array
    {
        $rule = ['mp3'];
        return UploadLibrary::uploadFile('audios', $rule, 20);
    }
}
